Skip to content

Conversation

@smsharma
Copy link
Collaborator

The Bug

File: linx/reactions.py, line 161

else:
    return TypeError('Must include spline data points or analytic...')

This returns a TypeError instance instead of raising it.

Impact

When a Reaction is created without providing either spline_data or frwrd_rate_param_func:

  1. __init__ returns a TypeError object (which is truthy, not an error)
  2. Object construction appears to "succeed"
  3. The reaction object is in an invalid state (missing required data)
  4. Causes cryptic failures later when the object is actually used

Example of the problem

# This SHOULD fail but doesn't:
rxn = Reaction(name="bad", in_states=(...), out_states=(...), 
               alpha=1, beta=2, gamma=3)
# rxn is now a TypeError instance, not a Reaction!

# Later code fails mysteriously:
rxn.frwrd_rate_param(T, p)  # AttributeError: 'TypeError' has no attribute...

The Fix

Change return TypeError(...)raise TypeError(...)

🤖 Generated with Claude Code

BUG: Line 161 used `return TypeError(...)` instead of `raise TypeError(...)`.

This meant that when a Reaction was created without either spline_data
or frwrd_rate_param_func, the __init__ method would:
1. Return a TypeError instance (which is truthy, not an error)
2. Allow object construction to "succeed"
3. Cause cryptic failures later when the object is used

The fix changes `return` to `raise` so invalid Reaction construction
properly fails with a clear error message.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@smsharma smsharma requested a review from cgiovanetti January 24, 2026 02:30
Copy link
Owner

@cgiovanetti cgiovanetti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good catch!

@cgiovanetti cgiovanetti merged commit 71cd19c into main Jan 26, 2026
1 check passed
@cgiovanetti cgiovanetti deleted the siddharth/fix-raise-typeerror branch January 26, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants